<?php
/**
 * Class rail_root
 *
 * The rail_root object is unique in each rail. A rail_root has no environment and act as the start object in the rail. It's not
 * possible to move a rail_root object into an other rail_object.
 *
 * The rail_root object provides the protected attribute RAIL_VERSION includes the version of the PHPrail used to create
 * this rail. The RAIL_VERSION attribute is only readable.
 *
 * If deleting the rail_root the tree is empty.
 *
 **
 * rail_object
 *   |
 *   + rail_sequence
 *       |
 *       + rail_container
 *           |
 *           + rail_root
 *
 * PHP versions 5
 * See http://www.open-rail.org for more informations.
 *
 **
 * Copyright (C)
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of ERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software
 * Fundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 *
 **
 * @author Bastian Che Schröder <bastian@open-rail.org>
 * @version 2009-05-16
 * @package rail
 */
final class rail_root extends rail_container {

	/**
	 * Attributes which are not writeable from outside. Outside means by calling set_attribute(s) method.
	 * The array contains only the name of protected attributes not the attribute itself.
	 *
	 * @var array
	 */
	protected $protected_attributes = array( OBJ_TIME_CREATE, OBJ_TIME_LASTWRITE, RAIL_VERSION );

	
	/**
	 * Throw an Exception if called, because it's not allowed to have more then one rail_root.
	 *
	 * @exception rail_exception
	 */	
	public static function create ( /*$pRailConnector, $pEnvironment, $pName = 'new object'*/ ) {
		throw new rail_exception( $this, 'Only one root_object allowed.' );
	}

	
	/**
	 * Throw an Exception if called, because rail_root has no environment.
	 *
	 * @exception rail_exception
	 */
	public function get_environment () {
		throw new rail_exception( $this, 'The root container has no environment.' );
	}


	/**
	 * The path for the rail_root is a '/' symbol.
	 *
	 * @return string
	 */
	public function get_path () {
		return $this->cache[ 'path' ] = '/';
	}


	/**
	 * The rail_root can't move into an other rail_object.
	 *
	 * @exception rail_exception
	 * @param rail_object $pRailObject
	 */
	public function move ( $pRailObject ) {
		throw new rail_exception( $this, 'The root container can\'t move to ' . $pRailObject->get_path() . '.' );
	}

} // End of rail_root
?>